<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="assets/css/layui.css">
    <link rel="stylesheet" href="assets/css/admin.css">
    <link rel="icon" href="/favicon.ico">
    <title>管理后台</title>
</head>
<body class="layui-layout-body">
    <div class="layui-layout layui-layout-admin">
        <div class="layui-header custom-header">
            
            <ul class="layui-nav layui-layout-left">
                <li class="layui-nav-item slide-sidebar" lay-unselect>
                    <a href="javascript:;" class="icon-font"><i class="ai ai-menufold"></i></a>
                </li>
            </ul>

            <ul class="layui-nav layui-layout-right">
                <li class="layui-nav-item">
                    <a href="javascript:;" id="username">God of the Group One<span class="layui-nav-more"></span></a>
                    <dl class="layui-nav-child">
                        <dd><a href="">帮助中心</a></dd>
                        <dd><a id="exit">退出</a></dd>
                    </dl>
                </li>
            </ul>
        </div>

        <div class="layui-side custom-admin">
            <div class="layui-side-scroll">

                <div class="custom-logo">
                    <img src="assets/images/logo.png" alt=""/>
                    <h1>川邮学生会OA系统</h1>
                </div>
                <ul id="Nav" class="layui-nav layui-nav-tree">
                    <li class="layui-nav-item">
                        <a href="javascript:;">
                            <i class="layui-icon">&#xe609;</i>
                            <em>主页</em>
                        </a>
                        <dl class="layui-nav-child">
                            <dd><a href="views/console.html">控制台</a></dd>
                        </dl>
                    </li>
                    <li class="layui-nav-item">
                        <a href="javascript:;">
                            <i class="layui-icon">&#xe612;</i>
                            <em>人员管理</em>
                        </a>
                        <dl id="user" class="layui-nav-child">
                            <dd><a href="views/userlist.html">用户组</a></dd>
                            <dd><a href="views/userInfo.html">个人信息</a></dd>

                        </dl>
                    </li>
                    <li class="layui-nav-item">
                        <a href="javascript:;">
                            <i class="layui-icon">&#xe622;</i>
                            <em>活动管理</em>
                        </a>
                        <dl id="activity" class="layui-nav-child">
                            <dd><a href="views/activitylist.html">活动列表</a></dd>
                        </dl>
                    </li>
                </ul>

            </div>
        </div>

        <div class="layui-body">
             <div class="layui-tab app-container" lay-allowClose="true" lay-filter="tabs">
                <ul id="appTabs" class="layui-tab-title custom-tab"></ul>
                <div id="appTabPage" class="layui-tab-content"></div>
            </div>
        </div>

        <div class="layui-footer">
            <p>Copy Right © 2019：<a href="#" target="_blank">God of the Group One</a></p>
        </div>

        <div class="mobile-mask"></div>
    </div>
    <script src="assets/layui.js"></script>
    <script src="index.js" data-main="home"></script>
    <script>

        layui.use('jquery',function () {
            var $ = layui.jquery;
            function exit(){
                $.ajax({
                    url: 'exit.do',
                    dataType: 'json',
                    type: 'post',
                    success: function(data) {
                        if (data.code == '1'){
                            layer.msg("未知错误");
                        }else if (data.code == '0'){
                            location.href = "login.html";
                        }
                    }
                })
            }
            $("#exit").click(function () {
                exit();
            });
            var department = " <li class=\"layui-nav-item\">\n" +
                "                        <a href=\"javascript:;\">\n" +
                "                            <i class=\"layui-icon\">&#xe857;</i>\n" +
                "                            <em>部门管理</em>\n" +
                "                        </a>\n" +
                "                        <dl class=\"layui-nav-child\">\n" +
                "                            <dd><a href=\"views/form.html\">添加部门</a></dd>\n" +
                "                        </dl>\n" +
                "                    </li>";
            var user = "<dd><a href=\"views/userAdd.html\">添加用户</a></dd>";
            var activity = "<dd><a href=\"views/activityadd.html\">添加活动</a></dd>";
            $.ajax({
                url: 'user.do',
                data: {
                    'tran':'select',
                    'get':'info',
                    'id':'self'
                },
                dataType: 'json',
                type: 'post',
                async: false,
                success: function(data) {
                    if (data.permissions == '0') {
                        $("#Nav").append(department);
                        $("#user").append(user);
                        $("#activity").append(activity);
                    }else if(data.permissions <= '1'){
                        $("#user").append(user);
                        $("#activity").append(activity);

                    }

                }
            });

            $.ajax({
                url: 'UserServlet.do',
                data: {
                    'transaction':'select',
                    'get':'username'
                },
                dataType: 'json',
                type: 'post',
                success: function(data) {
                    var username = $("#username");
                    console.log(data)
                    username.text(data.username);
                    console.log();
                }
            })
        });
    </script>
</body>
</html>